package com.dream.dynamic_datasource.config.properties;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.util.StringUtils;

import java.util.Arrays;

/**
 * @author emiyakiri
 */
@ConfigurationProperties("cors")
public class CorsProperties {
    private String header;
    private String method;
    private String[] origin;

    public String getHeader() {
        return header;
    }

    public void setHeader(String header) {
        this.header = header;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String[] getOrigin() {
        return origin;
    }

    public void setOrigin(String[] origin) {
        this.origin = Arrays.stream(origin).distinct().filter(it -> !StringUtils.isEmpty(it)).toArray(String[]::new);
    }
}
